package com.ruix.app.model;

import android.text.TextUtils;

import org.json.JSONObject;

/**
 * Created by hadexs on 2017/4/26.
 */

public class ClassMenber {
    private String name;
    private String avatar;
    private String id;
    private String roleName;
    private String role;
    private String locate;
    private String company;
    private boolean disableSendMsg;

    public ClassMenber parse(JSONObject object){
        if (object != null){
            setRoleName(object.optString("roleName",""));
            setId(object.optString("id",""));
            setName(object.optString("name",""));
            setAvatar(object.optString("avatar",""));
            setRole(object.optString("role","0"));
            setLocate(object.optString("locate",""));
            setCompany(object.optString("company",""));
            setDisableSendMsg(object.optInt("prohibited",0)==1);
        }
        return this;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getRoleName() {
        return roleName;
    }

    public String authorRoleValue(boolean isTeacherCircle){
        if (!TextUtils.isEmpty(role)) {
            if (Role.RoleMentor.role().equals(role)){
                return Role.RoleMentor.value();
            } else if (Role.RoleSignPics.role().equals(role)){
                return Role.RoleSignPics.value();
            } else if (Role.RoleGuest.role().equals(role)){
                return Role.RoleGuest.value();
            } else if (Role.RoleAdviser.role().equals(role)){
                if (isTeacherCircle){
                    return Role.RoleMentor.value();
                }
                return Role.RoleAdviser.value();
            } else if (Role.RoleCommittee.role().equals(role)){
                return Role.RoleCommittee.value();
            } else if (Role.RoleMonitor.role().equals(role)){
                return Role.RoleMonitor.value();
            } else if (Role.RoleSchoolmate.role().equals(role)){
                return null;
            }
        }

        return null;
    }




    public boolean isDisplayRole(){
        if("50".equals(role)){
            return false;
        }
        return true;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getRole() {
        return role;
    }

    public void setRole(String role) {
        this.role = role;
    }

    public String getLocate() {
        return locate;
    }

    public void setLocate(String locate) {
        this.locate = locate;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public boolean isDisableSendMsg() {
        return disableSendMsg;
    }

    public void setDisableSendMsg(boolean disableSendMsg) {
        this.disableSendMsg = disableSendMsg;
    }
}
